<template>
  <div class="content">
    <div class="serach">
      <view class="section" @click="serch()">
        <img src="../../images/icon/search.png" alt class="search-img" />
        <text class="placeholder">搜索</text>
      </view>
    </div>
    <div class="imges">
      <div class="img">
        <MySwiper />
      </div>
      <div class="navitem">
        <div @click="toRecommend()" class="toClassifyPage">
          <img src="../../static/images/icon/newProd.png" alt />
          <span>新品推荐</span>
        </div>
        <div @click="toSpringSale()" class="toClassifyPage">
          <img src="../../static/images/icon/timePrice.png" alt />
          <span>限时特惠</span>
        </div>
        <div @click="toDailyrushed()" class="toClassifyPage">
          <img src="../../static/images/icon/neweveryday.png" alt />
          <span>每日疯抢</span>
        </div>
      </div>
      <div class="message-play">
        <!-- <img src="../../static/images/icon/horn.png" alt />
        <swiper class="swiper-cont" current="1">
          <swiper-item class="items">同是纯棉，为什么它睡起来如此舒服</swiper-item>
          <swiper-item class="items">超大容量折叠包，再也不担心旅游购物买爆</swiper-item>
          <swiper-item class="items">两种意见 | 早餐绝配，松软到怀疑人生的酵母面包</swiper-item>
        </swiper>
        <span class="arrow"></span> -->
        <News :noticeList='noticeList'/>
      </div>
    </div>
    <div>
      <div v-for="(items) in listTitle" :key="items.id">
        <div v-if="items.id===1">
          <!-- 每日上新 -->
          <div class="up-to-date">
            <div class="title">
              <span>每日上新</span>
              <div class="more-prod-cont">
                <span class="more">查看更多</span>
              </div>
            </div>
            <div class="item-cont">
              <div class="prod-item" v-for="(item) in list" :key="item.prodId">
                <div @click="toProdDetails(item.prodId)">
                  <div class="imagecont">
                    <img class="prodimg" :src="item.pic" />
                  </div>
                  <div class="prod-text">{{item.brief}}</div>
                  <div class="price">￥{{item.price}}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div v-if="items.id===2">
          <!-- 商城热卖 -->
          <div class="hot-sale">
            <div class="title">
              <span>{{listTitle[0].title}}</span>
              <div class="more-prod-cont">
                <span class="more" @click="more()">更多</span>
                <span class="arrow"></span>
              </div>
            </div>
            <div class="hotsale-item-cont">
              <div class="prod-items" v-for="(item) in list" :key="item.prodId">
                <div @click="toProdDetails(item.prodId)">
                  <div class="hot-imagecont">
                    <img class="hotsaleimg" :src="item.pic" />
                  </div>
                  <div class="hot-text">
                    <div class="hotprod-text">{{item.prodName}}</div>
                    <div class="prod-info">{{item.brief}}</div>
                    <div class="prod-text-info">
                      <div class="price">
                        <span class="symbol">￥</span>
                        <span class="big-num">{{item.price}}</span>
                        <span class="small-num">.1</span>
                      </div>
                      <img class="basket-img" src="../../static/images/tabbar/basket-sel.png" alt />
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div v-if="items.id===3">
          <!-- 更多宝贝 -->
          <div class="more-prod">
            <div class="title">{{listTitle[1].title}}</div>
            <div class="prod-show">
              <div class="show-item" v-for="(item) in list" :key="item.prodId">
                <div @click="toProdDetails(item.prodId)" class="more-prod-pic">
                  <img class="more-pic" :src="item.pic" alt />
                </div>
                <div @click="toProdDetails(item.prodId)" class="prod-text-right">
                  <div class="prod-text more">{{item.prodName}}</div>
                  <div class="prod-info">{{item.brief}}</div>
                  <div class="b-cart">
                    <div class="price">
                      <span class="symbol">￥</span>
                      <span class="big-num">{{item.price}}</span>
                      <span class="small-num"></span>
                    </div>
                    <img class="basket-img" src="../../static/images/tabbar/basket-sel.png" alt />
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import MySwiper from "../../components/my-swiper.vue";
import { mapActions, mapMutations, mapState } from "vuex";
import News from "../../components/news.vue";
export default {
  components: {
    MySwiper,
    News,
  },
  data() {
    return {
      title: "Hello",
    };
  },
  methods: {
    ...mapActions({
      homeList: "home/homeList",
      homeListTitle: "home/homeListTitle",
      getnoticeList: "recentNews/getnoticeList",
    }),
    // ...mapMutations("homeList", ["get_list",'get_homeListTitle'])
    // nav新品推荐详情
    toRecommend() {
      uni.navigateTo({
        url: "/pages/prod-classify/index?class=lastedProdPage&current=1"
      });
    },
    // nav 限时特惠详情
    toSpringSale() {
      uni.navigateTo({
        url: "/pages/prod-classify/index?class=discountProdList&current=1"
      });
    },
    // nav 每日疯抢详情
    toDailyrushed() {
      uni.navigateTo({
        url: "/pages/prod-classify/index?class=moreBuyProdList&current=1"
      });
    },
    // 列表详情
    toProdDetails(id) {
      console.log(id);
      uni.navigateTo({
        url: `/pages/prod/prod?detailsId=${id}`
      });
    },
    //跳转搜索页
    serch() {
      uni.navigateTo({
        url: "/pages/search-page/index",
      });
    },
    // 更多
    more() {
      uni.navigateTo({
        url: "/pages/prod-classify/index?class=moreBuyProdList&current=1"
      });
    }
  },
  async mounted() {
    await this.homeList();
    await this.homeListTitle();
    await this.getnoticeList();
    console.log(this.noticeList, "*******");
  },


  computed: {
    ...mapState("home", ["list", "listTitle"]),
    ...mapState({
      noticeList: (state) => state.recentNews.noticeList,
    }),
  },
};
</script>

<style scoped>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.serach {
  width: 100%;
  height: 80rpx;
}
.imges {
  width: 100%;
}
.img {
  widows: 100%;
  height: 422rpx;
}
.navitem {
  display: flex;
  justify-content: space-between;
  background: #fff;
  padding-top: 20rpx;
  padding-bottom: 30rpx;
}
.toClassifyPage {
  width: 25%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto;
}
.navitem .toClassifyPage img {
  width: 75rpx;
  height: 75rpx;
}
.navitem .toClassifyPage text {
  font-size: 26rpx;
  margin-top: 20rpx;
}
.message-play {
  position: relative;
  height: 90rpx;
  background: #fff;
  margin: auto;
  padding: 0 20rpx;
  border: 2rpx solid #fafafa;
}
.message-play img {
  width: 77rpx;
  height: 36rpx;
  position: absolute;
  left: 20rpx;
  top: 27rpx;
  margin-right: 8rpx;
}
.message-play .swiper-cont {
  height: 90rpx;
  line-height: 90rpx;
}
.arrow {
  width: 15rpx;
  height: 15rpx;
  border-top: 3rpx solid #686868;
  border-right: 3rpx solid #686868;
  transform: rotate(45deg);
  position: absolute;
  right: 30rpx;
  top: 34rpx;
}
.message-play .swiper-cont .items {
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  text-align: left;
  font-size: 28rpx;
  font-weight: bold;
  overflow: hidden;
  will-change: transform;
  color: #474747;
}
.up-to-date {
  background-image: url("");
  background-position: top;
  background-size: 100% 332rpx;
  background-repeat: no-repeat;
  background-color: #fff;
}
.up-to-date .title {
  color: #fff;
  background: none;
  position: relative;
  height: 64rpx;
  line-height: 64rpx;
  font-size: 32rpx;
  padding: 40rpx 0 10rpx 30rpx;
  color: #333;
}
.up-to-date .title .more-prod-cont {
  color: #999;
  display: inline-block;
  text-align: right;
}
.up-to-date .title .more-prod-cont .more {
  position: absolute;
  right: 30rpx;
  top: 48rpx;
  color: #fff;
  font-size: 24rpx;
  background: #65addf;
  border-radius: 30rpx;
  padding: 0 30rpx;
  height: 44rpx;
  line-height: 44rpx;
}
.up-to-date .item-cont {
  margin: auto;
  height: auto;
  width: calc(100% - 40rpx);
  padding: 0 20rpx;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}
.up-to-date .item-cont .prod-item {
  border-radius: 10rpx;
  width: 220rpx;
  background: #fff;
  display: inline-block;
  margin-bottom: 20rpx;
  box-shadow: 0rpx 6rpx 8rpx rgba(58, 134, 185, 0.2);
}
.up-to-date .item-cont .prod-item .imagecont {
  width: 100%;
  font-size: 0;
}
.up-to-date .item-cont .prod-item .imagecont .prodimg {
  width: 220rpx;
  height: 220rpx;
  vertical-align: middle;
  border-top-left-radius: 10rpx;
  border-top-right-radius: 10rpx;
  font-size: 0;
}
.up-to-date .item-cont .prod-item .prod-text {
  font-size: 28rpx;
  overflow: hidden;
  margin: 10rpx 0;
  height: 68rpx;
  display: -webkit-box;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: #000;
  padding: 0 10rpx;
}

.hot-sale .title {
  position: relative;
  height: 64rpx;
  line-height: 64rpx;
  font-size: 32rpx;
  padding: 40rpx 0 10rpx 30rpx;
  color: #333;
  background: #fff;
}
.title .more-prod-cont {
  color: #999;
  display: inline-block;
  text-align: right;
}
.title .more-prod-cont .more {
  position: absolute;
  right: 30rpx;
  top: 48rpx;
  color: #666;
  font-size: 24rpx;
  padding: 0 20rpx;
  height: 44rpx;
  line-height: 44rpx;
}
.title .more-prod-cont .arrow {
  top: 58rpx;
  right: 30rpx;
  border-top: 2rpx solid #666;
  border-right: 2rpx solid #666;
  transform: rotate(45deg);
  position: absolute;
  width: 15rpx;
  height: 15rpx;
}
.hotsale-item-cont {
  padding-bottom: 20rpx;
  background: #fff;
}
.hot-sale .prod-items:nth-child(2n-1) {
  margin: 20rpx 10rpx 10rpx 20rpx;
}
.hot-sale .prod-items {
  width: 345rpx;
  display: inline-block;
  background: #fff;
  padding-bottom: 20rpx;
  box-sizing: border-box;
  box-shadow: 0rpx 6rpx 8rpx rgba(58, 134, 185, 0.2);
}
.prod-items .hot-imagecont {
  font-size: 0;
  text-align: center;
}
.prod-items .hot-imagecont .hotsaleimg {
  width: 341rpx;
  height: 341rpx;
}
.prod-items .hot-text {
  margin-top: 20rpx;
  padding: 0 10rpx;
}

.prod-items .hot-text .hotprod-text {
  font-size: 28rpx;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prod-items .hot-text .prod-info,
.more-prod .prod-text-right .prod-info {
  font-size: 22rpx;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prod-items .hot-text .prod-text-info {
  position: relative;
  height: 70rpx;
  line-height: 70rpx;
  font-family: Arial;
}
.price {
  font-family: Arial;
  display: inline-block;
  color: #eb2444;
  padding-bottom: 10rpx;
  padding-left: 10rpx;
}
.symbol {
  font-size: 24rpx;
}
.big-num {
  font-size: 32rpx;
}
.small-num {
  font-size: 24rpx;
}
.prod-items .hot-text .prod-text-info .basket-img {
  width: 50rpx;
  height: 50rpx;
  position: absolute;
  right: 0;
  bottom: 7rpx;
  padding: 8rpx;
}
img {
  width: 320px;
  height: 240px;
  display: inline-block;
  overflow: hidden;
}
.more-prod {
  background: #fff;
}
.title {
  position: relative;
  height: 64rpx;
  line-height: 64rpx;
  font-size: 32rpx;
  padding: 40rpx 0 10rpx 30rpx;
  color: #333;
  background: #fff;
}
.more-prod .prod-show .show-item {
  position: relative;
  display: flex;
  padding: 20rpx;
  justify-content: start;
  border-top: 2rpx solid #f4f4f4;
}
.more-prod .prod-show .show-item .more-prod-pic {
  width: 250rpx;
  height: 250rpx;
}
.more-prod .prod-show .show-item .more-prod-pic .more-pic {
  max-width: 100%;
  max-height: 100%;
}
img {
  width: 320px;
  height: 240px;
  display: inline-block;
  overflow: hidden;
}
.more-prod .prod-show .show-item .prod-text-right {
  margin-left: 30rpx;
  width: 72%;
  padding-bottom: 10rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.more-prod .prod-show .show-item .prod-text-right .prod-text.more {
  margin: 0;
  font-size: 28rpx;
  overflow: hidden;
  margin-bottom: 20rpx;
  display: -webkit-box;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.prod-items .hot-text .prod-info,
.more-prod .prod-text-right .prod-info {
  font-size: 22rpx;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.b-cart {
  margin-top: 30rpx;
}
.price {
  font-family: Arial;
  display: inline-block;
  color: #eb2444;
  padding-bottom: 10rpx;
  padding-left: 10rpx;
}
.symbol {
  font-size: 24rpx;
}
.big-num {
  font-size: 32rpx;
}
.small-num {
  font-size: 24rpx;
}
.b-cart .basket-img {
  width: 50rpx;
  height: 50rpx;
  position: absolute;
  right: 46rpx;
  padding: 8rpx;
}
.search-img {
  width: 32rpx;
  height: 32rpx;
  margin-right: 10rpx;
}
.section {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 60rpx;
  background: #fff;
  z-index: 1;
  border-radius: 50rpx;
  width: 92%;
  margin: auto;
  left: 4%;
  background: #f7f7f7;
}
.section .placeholder {
  display: block;
  font-size: 24rpx;
  color: #999;
}
</style>



